import requests
from threading import Thread
from multiprocessing import Process

def request_baidu(index):
    url = 'https://www.baidu.com/'
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36'
    }
    result = requests.get(url=url,headers=headers)
    print(result.status_code)
    return result
if __name__ == "__main__":
    thread_arr = []
    for i in range(10):
        t = Thread(target=request_baidu, args=(i, ))
        thread_arr.append(t)
        t.start()
    for i in thread_arr:
        i.join()
    print('--------------------多线程：ok!--------------------')

    process_arr = []
    for i in range(10):
        p = Process(target=request_baidu, args=(i, ))
        process_arr.append(p)
        p.start()
    for i in process_arr:
        i.join()
    print('--------------------多进程：ok!--------------------')
